<?php 

//$parameters='private=1&seller_name=&manager=&email=lkjlkjl%40jj.ww&phone=65456464656&location_id=637640&metro_id=2&district_id=&category_id=114&params%5B716%5D=10213&title=Kljlk&description=.knk.ml&price=0&image=&service_code=free';


$host = 'http://m.avito.ru/add/confirm';
$referer = 'http://m.avito.ru/add/confirm';
$host = 'http://m.avito.ru/add/confirm';
$referer = 'http://m.avito.ru/add/confirm';
/*$ch = curl_init();
$fp = fopen('./images/logo.png', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);*/
$password = 'qqqqqx';
//$password = 'qqqqq';
$captcha = $_GET['c'];
//var_dump(urlencode('Готово →'));
//var_dump(urldecode('%D0%93%D0%BE%D1%82%D0%BE%D0%B2%D0%BE+%E2%86%92'));
//$parameters = 'password='.$password.'&confirm='.$password.'&captcha='.$captcha.'&add=%D0%93%D0%BE%D1%82%D0%BE%D0%B2%D0%BE+%E2%86%92';
$parameters = array(
		'password' => $password,
		'confirm' => 'qqqqqx',
		'captcha' => $captcha,
		'add' => '%D0%93%D0%BE%D1%82%D0%BE%D0%B2%D0%BE+%E2%86%92'
		);

var_dump($captcha);
//$captcha = iconv("koi8-r","windows-1251",$captcha);
//var_dump($captcha);
//iconv("windows-1251","utf-8",$string);
//var_dump($_POST);
//var_dump($_GET);
//$parameters = '';

$ch = curl_init();

curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_COOKIEJAR,$_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE,$_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$parameters);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt ($ch, CURLOPT_VERBOSE, 2); // Отображать детальную информацию о соединении
curl_setopt ($ch, CURLOPT_ENCODING, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
///var_dump($_COOKIE);
$hdr=array(
		'User-Agent: BlackBerry9530/4.7 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105',
		'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
		'Host m.avito.ru',
		'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
		'Accept-Encoding: gzip, deflate',
		'Connection: keep-alive',
		'Content-Type: multipart/form-data',
		'Expect:'

);

curl_setopt($ch, CURLOPT_HTTPHEADER,$hdr);
$result = curl_exec($ch);

curl_close($ch);

echo $result;
var_dump($result);
?>